﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace diploma.core.data.subobjects
{
    public class PropertyValue : ISerializable
    {
        private string title;
        private string _value;
        private long id_parent;

        public PropertyValue(long _id_parent, string _title, string __value)
        {
            title = _title;
            id_parent = _id_parent;
            _value = __value;
        }

        public PropertyValue() { }

        public override string ToString()
        {
            return title + " : " + _value;
        }

        public string Value
        {
            get
            {
                return _value;
            }
            set
            {
                _value = value;
            }

        }

        public string Title
        {
            get
            {
                return title;
            }
            set
            {
                title = value;
            }
        }

        public long IdParent
        {
            get
            {
                return id_parent;
            }
        }

        #region ISerializable Members

        public void FromStream(System.IO.Stream _stream)
        {
            id_parent = ByteSerialization.IntFromBytes(_stream);
            title = ByteSerialization.StringFromBytes(_stream);
            _value = ByteSerialization.StringFromBytes(_stream);
        }

        public void ToStream(System.IO.Stream _stream)
        {
            ByteSerialization.LongToBytes(_stream, id_parent);
            ByteSerialization.StringToBytes(_stream, title);
            ByteSerialization.StringToBytes(_stream, _value);
        }

        #endregion
    }
}
